package com.quick.config;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.quick.Quick;
import com.quick.spring.SpringUtil;

public class QuickSystem {
	public static HttpServletRequest getRequest() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        return request;
    }
	
	public static String getKey(String token) {
		String source = getRequest().getHeader("source");
		StringBuffer key = new StringBuffer(source);
		key.append("::").append(token);
		return key.toString();
	}

	public static String getSource() {
		String source = getRequest().getHeader("source");
		return source;
	}

	public static String getFullKey() {
		Quick  quick = SpringUtil.getBean(Quick.class);
		Map<String, Object> develop = quick.getDevelop();
		QuickProperties basis = (QuickProperties) develop.get("basis");
		String token = SpringUtil.getRequest().getHeader(basis.getTokenKey());
		return  getKey(token);
	}

}
